#include "knight.h"
#include <stdio.h>
	
Knight::Knight(){

}
Knight::Knight(bool c, int r, int f){
	//static GLMmodel* knight_model = loadModel("knight.obj");
	color = c;
	rank = r;
	file = f;
}

void Knight::getLegalMoves(position* moves, int numMoves){

}

void Knight::drawPiece(){
	//Load the model if not loaded already
	static GLfloat model_dimensions[3];
	static GLMmodel* knight_model = loadModel("Pieces/knight.obj", model_dimensions);

    if(color == WHITE){
        glColor3f(1,1,1);
    }else{
        glColor3f(0.2,0.2,0.2);
    }

	glPushMatrix();
    glTranslatef(file-0.5, .01, rank - 0.5);
	glTranslatef(0, model_dimensions[1]/2, 0);
	if(color == WHITE) 
		glRotatef(180, 0, 1, 0);
	glmDraw(knight_model, GLM_FLAT);

	glPopMatrix();
}

GLMmodel* Knight::loadModel(char *file, GLfloat* dim){
	GLMmodel* model = glmReadOBJ(file);
	
	glmUnitize(model);
    glmFacetNormals(model);
    glmVertexNormals(model, 90.0);
    //GLfloat dimensions[3];
    glmDimensions(model, dim);

    //Scale the model to fit on unit squares
    //GLfloat max = (dimensions[0] > dimensions[2]) ? dimensions[0] : dimensions[2];
    //glmScale(model, 1/max);
    return model;
}